package com.ruoyi.web.controller.combat;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.CombatCount;
import com.ruoyi.combat.service.ICombatCountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 统计Controller
 * 
 * @author ruoyi
 * @date 2025-04-09
 */
@RestController
@RequestMapping("/combat/count")
@Anonymous
@Api(tags = "网管统计数据接口")
public class CombatCountController extends BaseController
{
    @Autowired
    private ICombatCountService combatCountService;


    @ApiOperation("统计数据")
    @GetMapping("/getCount")
    public AjaxResult getCount()
    {
        combatCountService.CountDataByDay();
        return AjaxResult.success();
    }

    /**
     * 查询统计列表
     */
    @PreAuthorize("@ss.hasPermi('combat:count:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatCount combatCount)
    {
        startPage();
        List<CombatCount> list = combatCountService.selectCombatCountList(combatCount);
        return getDataTable(list);
    }

    /**
     * 导出统计列表
     */
    @PostMapping("/export")
    @ApiOperation("列表")
    public void export(HttpServletResponse response, CombatCount combatCount)
    {
        List<CombatCount> list = combatCountService.selectCombatCountList(combatCount);
        ExcelUtil<CombatCount> util = new ExcelUtil<CombatCount>(CombatCount.class);
        util.exportExcel(response, list, "统计数据");
    }

    /**
     * 获取统计详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatCountService.selectCombatCountById(id));
    }

    /**
     * 新增统计
     */
    @PostMapping
    @ApiOperation("新增")
    public AjaxResult add(@RequestBody CombatCount combatCount)
    {
        return toAjax(combatCountService.insertCombatCount(combatCount));
    }

    /**
     * 修改统计
     */
    @PutMapping
    public AjaxResult edit(@RequestBody CombatCount combatCount)
    {
        return toAjax(combatCountService.updateCombatCount(combatCount));
    }

    /**
     * 删除统计
     */
    @PreAuthorize("@ss.hasPermi('combat:count:remove')")
    @Log(title = "统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatCountService.deleteCombatCountByIds(ids));
    }
}
